<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
import Delete from "./../delete/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "plugin/team-dividend/admin/level/list",
        delete: "plugin/team-dividend/admin/level/destroyLevel",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {},
   
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "等级名称",
            prop: "name",
          },
          {
            label: "等级权重",
            prop: "level_weight",
          },
        ],
      },
      // 表格数据类型
      mixinTable_tableDataType: "tree",
    };
  },
  methods: {
    // 删除
    del(_id, data) {
      Delete.init({
        id: _id,
        data: data,
        onSuccess: () => {
          this.mixinTable_refreshData();
        } 
      })
    },
    // 禁用/启用
    async enable(_id,_activeId) {
      console.log(_id);
      this.$confirm("确定进行此操作吗？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        // type: "error",
        dangerouslyUseHTMLString: true,
      }).then(async () => {
        let res = await this.$vFN.Http.post({
          url: "plugin/team-dividend/admin/level/editActive",
          data: {
            level_id: _id,
            active: _activeId == 1 ? 0 : 1,
          }
        }, window);
        this.mixinTable_refreshData();
        if (res.code == 200) {
          this.$vFN.Tools.messageSuccess("操作成功");
        }
      }).catch(() => {});
    },
    // 打开添加/修改
    async editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
      });
    },
    // 初始化
    async init() {
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>